home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume5 / pbm3 / part2 < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  47.5 KB

  1. Path: xanth!nic.MR.NET!hal!ncoast!allbery
  2. From: jef@helios.ee.lbl.gov (Jef Poskanzer)
  3. Newsgroups: comp.sources.misc
  4. Subject: v05i042: pbm.shar2
  5. Message-ID: <8811010236.AA02694@helios.ee.lbl.gov>
  6. Date: 9 Nov 88 02:34:25 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: jef@helios.ee.lbl.gov (Jef Poskanzer)
  9. Lines: 1877
  10. Approved: allbery@ncoast.UUCP
  11.  
  12. Posting-number: Volume 5, Issue 42
  13. Submitted-by: "Jef Poskanzer" <jef@helios.ee.lbl.gov>
  14. Archive-name: pbm3/Part2
  15.  
  16. #! /bin/sh
  17. # This is a shell archive, meaning:
  18. # 1. Remove everything above the #! /bin/sh line.
  19. # 2. Save the resulting text in a file.
  20. # 3. Execute the file with /bin/sh (not csh) to create the files:
  21. #    xwdtopbm.1
  22. #    pbmtocbm.c
  23. #    pbmtocbm.1
  24. #    pbmtoicon.c
  25. #    pbmtoicon.1
  26. #    pbmtops.c
  27. #    pbmtops.1
  28. #    pbmtoptx.c
  29. #    pbmtoptx.1
  30. #    pbmtorast.c
  31. #    pbmtorast.1
  32. #    pbmtoxbm.c
  33. #    pbmtoxbm.1
  34. #    pbmtox10bm.c
  35. #    pbmtox10bm.1
  36. #    pbmtoascii.c
  37. #    pbmtoascii.1
  38. #    pbmcatlr.c
  39. #    pbmcatlr.1
  40. #    pbmcattb.c
  41. #    pbmcattb.1
  42. #    pbmfliplr.c
  43. #    pbmfliplr.1
  44. # This archive created: Mon Oct 31 18:33:31 1988
  45. # By:    Jef Poskanzer (Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal)
  46. export PATH; PATH=/bin:$PATH
  47. echo shar: extracting "'xwdtopbm.1'" '(1131 characters)'
  48. if test -f 'xwdtopbm.1'
  49. then
  50.     echo shar: will not over-write existing file "'xwdtopbm.1'"
  51. else
  52. sed 's/^X//' << \SHAR_EOF > 'xwdtopbm.1'
  53. X.TH xwdtopbm 1 "31 August 1988"
  54. X.SH NAME
  55. Xxwdtopbm - convert X11 and X10 window dump files into portable bitmaps
  56. X.SH SYNOPSIS
  57. Xxwdtopbm [xwdfile]
  58. X.SH DESCRIPTION
  59. XReads an X11 or X10 window dump file as input.
  60. XProduces a portable bitmap as output.
  61. X.LP
  62. XUsing this program, you can convert anything on an X workstation's screen
  63. Xinto a pbm bitmap.
  64. XJust display whatever you're interested in, do an xwd, run it through
  65. Xxwdtopbm, and then use pbmcut to select the part you want.
  66. X.LP
  67. XNote that this tool only works for monochrome dump files.
  68. X.SH BUGS
  69. XI haven't tested this tool with very many configurations, so there are
  70. Xprobably bugs.
  71. XPlease let me know if you find any.
  72. X.SH "SEE ALSO"
  73. Xpbmtoxwd(1), pbmtox10wd(1), pbm(5)
  74. X.SH AUTHOR
  75. XCopyright (C) 1988 by Jef Poskanzer.
  76. X
  77. XPermission to use, copy, modify, and distribute this software and its
  78. Xdocumentation for any purpose and without fee is hereby granted, provided
  79. Xthat the above copyright notice appear in all copies and that both that
  80. Xcopyright notice and this permission notice appear in supporting
  81. Xdocumentation.  This software is provided "as is" without express or
  82. Ximplied warranty.
  83. SHAR_EOF
  84. if test 1131 -ne "`wc -c < 'xwdtopbm.1'`"
  85. then
  86.     echo shar: error transmitting "'xwdtopbm.1'" '(should have been 1131 characters)'
  87. fi
  88. fi # end of overwriting check
  89. echo shar: extracting "'pbmtocbm.c'" '(1104 characters)'
  90. if test -f 'pbmtocbm.c'
  91. then
  92.     echo shar: will not over-write existing file "'pbmtocbm.c'"
  93. else
  94. sed 's/^X//' << \SHAR_EOF > 'pbmtocbm.c'
  95. X/* pbmtocbm.c - read a portable bitmap and produce a compact bitmap
  96. X**
  97. X** Copyright (C) 1988 by Jef Poskanzer.
  98. X**
  99. X** Permission to use, copy, modify, and distribute this software and its
  100. X** documentation for any purpose and without fee is hereby granted, provided
  101. X** that the above copyright notice appear in all copies and that both that
  102. X** copyright notice and this permission notice appear in supporting
  103. X** documentation.  This software is provided "as is" without express or
  104. X** implied warranty.
  105. X*/
  106. X
  107. X#include <stdio.h>
  108. X#include "pbm.h"
  109. X
  110. Xmain( argc, argv )
  111. Xint argc;
  112. Xchar *argv[];
  113. X    {
  114. X    FILE *ifd;
  115. X    bit **bits;
  116. X    int rows, cols, row, col;
  117. X
  118. X    if ( argc > 2 )
  119. X    {
  120. X    fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
  121. X    exit( 1 );
  122. X    }
  123. X
  124. X    if ( argc == 2 )
  125. X    {
  126. X        ifd = fopen( argv[1], "r" );
  127. X        if ( ifd == NULL )
  128. X        {
  129. X        fprintf( stderr, "%s: can't open.\n", argv[1] );
  130. X        exit( 1 );
  131. X        }
  132. X    }
  133. X    else
  134. X    ifd = stdin;
  135. X
  136. X    bits = pbm_readpbm( ifd, &cols, &rows );
  137. X
  138. X    if ( ifd != stdin )
  139. X    fclose( ifd );
  140. X    
  141. X    pbm_writecbm( stdout, bits, cols, rows );
  142. X
  143. X    exit( 0 );
  144. X    }
  145. SHAR_EOF
  146. if test 1104 -ne "`wc -c < 'pbmtocbm.c'`"
  147. then
  148.     echo shar: error transmitting "'pbmtocbm.c'" '(should have been 1104 characters)'
  149. fi
  150. fi # end of overwriting check
  151. echo shar: extracting "'pbmtocbm.1'" '(669 characters)'
  152. if test -f 'pbmtocbm.1'
  153. then
  154.     echo shar: will not over-write existing file "'pbmtocbm.1'"
  155. else
  156. sed 's/^X//' << \SHAR_EOF > 'pbmtocbm.1'
  157. X.TH pbmtocbm 1 "31 August 1988"
  158. X.SH NAME
  159. Xpbmtocbm - convert portable bitmaps into compact bitmaps
  160. X.SH SYNOPSIS
  161. Xpbmtocbm [pbmfile]
  162. X.SH DESCRIPTION
  163. XReads a portable bitmap as input.
  164. XProduces a compact bitmap as output.
  165. X.SH "SEE ALSO"
  166. Xcbmtopbm(1), pbm(5)
  167. X.SH AUTHOR
  168. XCopyright (C) 1988 by Jef Poskanzer.
  169. X
  170. XPermission to use, copy, modify, and distribute this software and its
  171. Xdocumentation for any purpose and without fee is hereby granted, provided
  172. Xthat the above copyright notice appear in all copies and that both that
  173. Xcopyright notice and this permission notice appear in supporting
  174. Xdocumentation.  This software is provided "as is" without express or
  175. Ximplied warranty.
  176. SHAR_EOF
  177. if test 669 -ne "`wc -c < 'pbmtocbm.1'`"
  178. then
  179.     echo shar: error transmitting "'pbmtocbm.1'" '(should have been 669 characters)'
  180. fi
  181. fi # end of overwriting check
  182. echo shar: extracting "'pbmtoicon.c'" '(2378 characters)'
  183. if test -f 'pbmtoicon.c'
  184. then
  185.     echo shar: will not over-write existing file "'pbmtoicon.c'"
  186. else
  187. sed 's/^X//' << \SHAR_EOF > 'pbmtoicon.c'
  188. X/* pbmtoicon.c - read a portable bitmap and produce a Sun icon file
  189. X**
  190. X** Copyright (C) 1988 by Jef Poskanzer.
  191. X**
  192. X** Permission to use, copy, modify, and distribute this software and its
  193. X** documentation for any purpose and without fee is hereby granted, provided
  194. X** that the above copyright notice appear in all copies and that both that
  195. X** copyright notice and this permission notice appear in supporting
  196. X** documentation.  This software is provided "as is" without express or
  197. X** implied warranty.
  198. X*/
  199. X
  200. X#include <stdio.h>
  201. X#include "pbm.h"
  202. X
  203. Xmain( argc, argv )
  204. Xint argc;
  205. Xchar *argv[];
  206. X    {
  207. X    FILE *ifd;
  208. X    bit **bits;
  209. X    int rows, cols, pad, padleft, padright, row, col;
  210. X    char ch;
  211. X
  212. X    if ( argc > 2 )
  213. X    {
  214. X    fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
  215. X    exit( 1 );
  216. X    }
  217. X
  218. X    if ( argc == 2 )
  219. X    {
  220. X        ifd = fopen( argv[1], "r" );
  221. X        if ( ifd == NULL )
  222. X        {
  223. X        fprintf( stderr, "%s: can't open.\n", argv[1] );
  224. X        exit( 1 );
  225. X        }
  226. X    }
  227. X    else
  228. X    ifd = stdin;
  229. X
  230. X    bits = pbm_readpbm( ifd, &cols, &rows );
  231. X
  232. X    if ( ifd != stdin )
  233. X    fclose( ifd );
  234. X    
  235. X    /* Round cols up to the nearest multiple of 16. */
  236. X    pad = ( ( cols + 15 ) / 16 ) * 16 - cols;
  237. X    padleft = pad / 2;
  238. X    padright = pad - padleft;
  239. X
  240. X    printf( "/* Format_version=1, Width=%d, Height=%d", cols + pad, rows );
  241. X    printf( ", Depth=1, Valid_bits_per_item=16\n */\n" );
  242. X
  243. X    putinit( );
  244. X    for ( row = 0; row < rows; row++ )
  245. X    {
  246. X    for ( col = 0; col < padleft; col++ )
  247. X        putbit( 0 );
  248. X        for ( col = 0; col < cols; col++ )
  249. X        putbit( bits[row][col] );
  250. X    for ( col = 0; col < padright; col++ )
  251. X        putbit( 0 );
  252. X        }
  253. X    putrest( );
  254. X
  255. X    exit( 0 );
  256. X    }
  257. X
  258. X
  259. Xint item, bitsperitem, bitshift, itemsperline, firstitem;
  260. X
  261. Xputinit( )
  262. X    {
  263. X    itemsperline = 0;
  264. X    bitsperitem = 0;
  265. X    item = 0;
  266. X    bitshift = 15;
  267. X    firstitem = 1;
  268. X    }
  269. X
  270. Xputbit( b )
  271. Xbit b;
  272. X    {
  273. X    if ( bitsperitem == 16 )
  274. X    putitem( );
  275. X    bitsperitem++;
  276. X    if ( b )
  277. X    item += 1 << bitshift;
  278. X    bitshift--;
  279. X    }
  280. X
  281. Xputrest( )
  282. X    {
  283. X    if ( bitsperitem > 0 )
  284. X    putitem( );
  285. X    putchar( '\n' );
  286. X    }
  287. X
  288. Xputitem( )
  289. X    {
  290. X    if ( firstitem )
  291. X    firstitem = 0;
  292. X    else
  293. X    putchar( ',' );
  294. X    if ( itemsperline == 8 )
  295. X    {
  296. X    putchar( '\n' );
  297. X    itemsperline = 0;
  298. X    }
  299. X    if ( itemsperline == 0 )
  300. X    putchar( '\t' );
  301. X    itemsperline++;
  302. X    printf( "0x%04x", item );
  303. X    bitsperitem = 0;
  304. X    item = 0;
  305. X    bitshift = 15;
  306. X    }
  307. SHAR_EOF
  308. if test 2378 -ne "`wc -c < 'pbmtoicon.c'`"
  309. then
  310.     echo shar: error transmitting "'pbmtoicon.c'" '(should have been 2378 characters)'
  311. fi
  312. fi # end of overwriting check
  313. echo shar: extracting "'pbmtoicon.1'" '(662 characters)'
  314. if test -f 'pbmtoicon.1'
  315. then
  316.     echo shar: will not over-write existing file "'pbmtoicon.1'"
  317. else
  318. sed 's/^X//' << \SHAR_EOF > 'pbmtoicon.1'
  319. X.TH pbmtoicon 1 "31 August 1988"
  320. X.SH NAME
  321. Xpbmtoicon - convert portable bitmaps into Sun icons 
  322. X.SH SYNOPSIS
  323. Xpbmtoicon [pbmfile]
  324. X.SH DESCRIPTION
  325. XReads a portable bitmap as input.
  326. XProduces a Sun icon as output.
  327. X.SH "SEE ALSO"
  328. Xicontopbm(1), pbm(5)
  329. X.SH AUTHOR
  330. XCopyright (C) 1988 by Jef Poskanzer.
  331. X
  332. XPermission to use, copy, modify, and distribute this software and its
  333. Xdocumentation for any purpose and without fee is hereby granted, provided
  334. Xthat the above copyright notice appear in all copies and that both that
  335. Xcopyright notice and this permission notice appear in supporting
  336. Xdocumentation.  This software is provided "as is" without express or
  337. Ximplied warranty.
  338. SHAR_EOF
  339. if test 662 -ne "`wc -c < 'pbmtoicon.1'`"
  340. then
  341.     echo shar: error transmitting "'pbmtoicon.1'" '(should have been 662 characters)'
  342. fi
  343. fi # end of overwriting check
  344. echo shar: extracting "'pbmtops.c'" '(6152 characters)'
  345. if test -f 'pbmtops.c'
  346. then
  347.     echo shar: will not over-write existing file "'pbmtops.c'"
  348. else
  349. sed 's/^X//' << \SHAR_EOF > 'pbmtops.c'
  350. X/* pbmtops.c - read a portable bitmap and produce a PostScript bitmap file
  351. X**
  352. X** Copyright (C) 1988 by Jef Poskanzer.
  353. X**
  354. X** Permission to use, copy, modify, and distribute this software and its
  355. X** documentation for any purpose and without fee is hereby granted, provided
  356. X** that the above copyright notice appear in all copies and that both that
  357. X** copyright notice and this permission notice appear in supporting
  358. X** documentation.  This software is provided "as is" without express or
  359. X** implied warranty.
  360. X*/
  361. X
  362. X#include <stdio.h>
  363. X#ifdef    OS_SYSV
  364. X#include <string.h>
  365. X#else    OS_SYSV
  366. X#include <strings.h>
  367. X#endif    OS_SYSV
  368. X#include "pbm.h"
  369. X
  370. Xmain( argc, argv )
  371. Xint argc;
  372. Xchar *argv[];
  373. X    {
  374. X    FILE *ifd;
  375. X    bit **bits;
  376. X    int argn, rows, cols, padright, row, col;
  377. X    char ch;
  378. X    float scale;
  379. X    char name[100], *cp;
  380. X    char *usage = "usage:  %s [-s scale] [pbmfile]\n";
  381. X
  382. X    argn = 1;
  383. X    scale = 1.0;
  384. X
  385. X    /* Check for flags. */
  386. X    if ( argn < argc )
  387. X    {
  388. X    if ( argv[argn][0] == '-' )
  389. X        {
  390. X        if ( ( argv[argn][1] == 's' || argv[argn][1] == 'S' ) &&
  391. X         argv[argn][2] == '\0' )
  392. X        {
  393. X        argn++;
  394. X        if ( argn == argc )
  395. X            {
  396. X            fprintf( stderr, usage, argv[0] );
  397. X            exit( 1 );
  398. X            }
  399. X        if ( sscanf( argv[argn], "%f", &scale ) != 1 )
  400. X            {
  401. X            fprintf( stderr, usage, argv[0] );
  402. X            exit( 1 );
  403. X            }
  404. X        argn++;
  405. X        }
  406. X        else
  407. X        {
  408. X        fprintf( stderr, usage, argv[0] );
  409. X        exit( 1 );
  410. X        }
  411. X        }
  412. X    }
  413. X
  414. X    if ( argn == argc )
  415. X    {
  416. X    ifd = stdin;
  417. X    strcpy( name, "noname" );
  418. X    }
  419. X    else
  420. X    {
  421. X        ifd = fopen( argv[argn], "r" );
  422. X        if ( ifd == NULL )
  423. X        {
  424. X        fprintf( stderr, "%s: can't open.\n", argv[argn] );
  425. X        exit( 1 );
  426. X        }
  427. X    strcpy( name, argv[argn] );
  428. X
  429. X#ifdef    OS_SYSV
  430. X    if ( ( cp = strchr( name, '.' ) ) != 0 )
  431. X#else    OS_SYSV
  432. X    if ( ( cp = index( name, '.' ) ) != 0 )
  433. X#endif    OS_SYSV
  434. X        *cp = '\0';
  435. X    argn++;
  436. X    }
  437. X
  438. X    if ( argn != argc )
  439. X    {
  440. X    fprintf( stderr, usage, argv[0] );
  441. X    exit( 1 );
  442. X    }
  443. X
  444. X    bits = pbm_readpbm( ifd, &cols, &rows );
  445. X
  446. X    if ( ifd != stdin )
  447. X    fclose( ifd );
  448. X    
  449. X    /* Compute padding to round cols up to the nearest multiple of 8. */
  450. X    padright = ( ( cols + 7 ) / 8 ) * 8 - cols;
  451. X
  452. X    putinit( name, cols, rows, scale );
  453. X    for ( row = 0; row < rows; row++ )
  454. X    {
  455. X        for ( col = 0; col < cols; col++ )
  456. X        putbit( bits[row][col] );
  457. X    for ( col = 0; col < padright; col++ )
  458. X        putbit( 0 );
  459. X        }
  460. X    putrest( );
  461. X
  462. X    exit( 0 );
  463. X    }
  464. X
  465. X
  466. Xint item, bitsperitem, bitshift, rlitemsperline;
  467. Xint repeat, itembuf[128], count, repeatitem, repeatcount;
  468. X
  469. Xputinit( name, cols, rows, scale )
  470. Xchar *name;
  471. Xint cols, rows;
  472. Xfloat scale;
  473. X    {
  474. X    int scols, srows;
  475. X
  476. X    scols = cols * scale * 0.96 + 0.5;    /*   0.96 is the multiple of   */
  477. X    srows = rows * scale * 0.96 + 0.5;    /* 72/300 that is closest to 1 */
  478. X
  479. X    printf( "%%! %s.ps\n", name );
  480. X    printf( "\n" );
  481. X    printf( "/rlestr1 1 string def\n" );
  482. X    printf( "/rlestr 128 string def\n" );
  483. X    printf( "/readrlestring {\n" );
  484. X    printf( "  currentfile rlestr1 readhexstring pop  0 get\n" );
  485. X    printf( "  dup 127 le {\n" );
  486. X    printf( "    currentfile rlestr 0  4 3 roll  1 add  getinterval\n" );
  487. X    printf( "    readhexstring  pop\n" );
  488. X    printf( "  } {\n" );
  489. X    printf( "    256 exch sub  dup\n" );
  490. X    printf( "    currentfile rlestr1 readhexstring pop  0 get\n" );
  491. X    printf( "    exch 0 exch 1 exch 1 sub { rlestr exch 2 index put } for\n" );
  492. X    printf( "    pop  rlestr exch 0 exch getinterval\n" );
  493. X    printf( "  } ifelse\n" );
  494. X    printf( "} bind def\n" );
  495. X    printf( "\n" );
  496. X    printf(
  497. X    "%d %d translate\t%% move to lower left corner of box\n",
  498. X    300 - ( scols/2 ), 400 - ( srows/2 ) );
  499. X    printf( "%d %d scale\t\t%% scale box\n", scols, srows );
  500. X    printf( "\n" );
  501. X    printf( "%d %d 1\t\t\t%% width height bits/sample\n", cols, rows );
  502. X    printf(
  503. X    "[ %d 0 0 -%d 0 %d ]\t%% transformation matrix\n", cols, rows, rows );
  504. X    printf( "{ readrlestring }\t%% proc\n" );
  505. X    printf( "image\n" );
  506. X
  507. X    rlitemsperline = 0;
  508. X    item = 0;
  509. X    bitsperitem = 0;
  510. X    bitshift = 7;
  511. X
  512. X    repeat = 1;
  513. X    count = 0;
  514. X    }
  515. X
  516. Xputrlitem( rlitem )
  517. Xint rlitem;
  518. X    {
  519. X    if ( rlitemsperline == 30 )
  520. X    {
  521. X    putchar( '\n' );
  522. X    rlitemsperline = 0;
  523. X    }
  524. X    rlitemsperline++;
  525. X    printf( "%02x", rlitem );
  526. X    }
  527. X
  528. Xputrlbuffer( )
  529. X    {
  530. X    int i;
  531. X
  532. X    if ( repeat )
  533. X    {
  534. X    putrlitem( 256 - count );
  535. X    putrlitem( repeatitem );
  536. X    }
  537. X    else
  538. X    {
  539. X    putrlitem( count - 1 );
  540. X    for ( i = 0; i < count; i++ )
  541. X        putrlitem( itembuf[i] );
  542. X    }
  543. X    repeat = 1;
  544. X    count = 0;
  545. X    }
  546. X
  547. Xputitem( )
  548. X    {
  549. X    int i;
  550. X
  551. X    if ( count == 128 )
  552. X    putrlbuffer( );
  553. X
  554. X    if ( repeat && count == 0 )
  555. X    { /* Still initializing a repeat buf. */
  556. X    itembuf[count] = repeatitem = item;
  557. X    count++;
  558. X    }
  559. X    else if ( repeat )
  560. X    { /* Repeating - watch for end of run. */
  561. X    if ( item == repeatitem )
  562. X        { /* Run continues. */
  563. X        itembuf[count] = item;
  564. X        count++;
  565. X        }
  566. X    else
  567. X        { /* Run ended - is it long enough to dump? */
  568. X        if ( count > 2 )
  569. X        { /* Yes, dump a repeat-mode buffer and start a new one. */
  570. X        putrlbuffer( );
  571. X        itembuf[count] = repeatitem = item;
  572. X        count++;
  573. X        }
  574. X        else
  575. X        { /* Not long enough - convert to non-repeat mode. */
  576. X        repeat = 0;
  577. X        itembuf[count] = repeatitem = item;
  578. X        count++;
  579. X        repeatcount = 1;
  580. X        }
  581. X        }
  582. X    }
  583. X    else
  584. X    { /* Not repeating - watch for a run worth repeating. */
  585. X    if ( item == repeatitem )
  586. X        { /* Possible run continues. */
  587. X        repeatcount++;
  588. X        if ( repeatcount > 3 )
  589. X        { /* Long enough - dump non-repeat part and start repeat. */
  590. X        count = count - ( repeatcount - 1 );
  591. X        putrlbuffer( );
  592. X        count = repeatcount;
  593. X        for ( i = 0; i < count; i++ )
  594. X            itembuf[i] = item;
  595. X        }
  596. X        else
  597. X        { /* Not long enough yet - continue as non-repeat buf. */
  598. X        itembuf[count] = item;
  599. X        count++;
  600. X        }
  601. X        }
  602. X    else
  603. X        { /* Broken run. */
  604. X        itembuf[count] = repeatitem = item;
  605. X        count++;
  606. X        repeatcount = 1;
  607. X        }
  608. X    }
  609. X
  610. X    item = 0;
  611. X    bitsperitem = 0;
  612. X    bitshift = 7;
  613. X    }
  614. X
  615. Xputbit( b )
  616. Xbit b;
  617. X    {
  618. X    if ( bitsperitem == 8 )
  619. X    {
  620. X    putitem( );
  621. X    }
  622. X    if ( ! b )
  623. X    item += 1 << bitshift;
  624. X    bitsperitem++;
  625. X    bitshift--;
  626. X    }
  627. X
  628. Xputrest( )
  629. X    {
  630. X    if ( bitsperitem > 0 )
  631. X    putitem( );
  632. X    if ( count > 0 )
  633. X    putrlbuffer( );
  634. X    printf( "\nshowpage\n" );
  635. X    }
  636. SHAR_EOF
  637. if test 6152 -ne "`wc -c < 'pbmtops.c'`"
  638. then
  639.     echo shar: error transmitting "'pbmtops.c'" '(should have been 6152 characters)'
  640. fi
  641. fi # end of overwriting check
  642. echo shar: extracting "'pbmtops.1'" '(1228 characters)'
  643. if test -f 'pbmtops.1'
  644. then
  645.     echo shar: will not over-write existing file "'pbmtops.1'"
  646. else
  647. sed 's/^X//' << \SHAR_EOF > 'pbmtops.1'
  648. X.TH pbmtops 1 "29 August 1988"
  649. X.SH NAME
  650. Xpbmtops - convert portable bitmaps into PostScript
  651. X.SH SYNOPSIS
  652. Xpbmtops [ -s <scale> ] [ <pbmfile> ]
  653. X.SH DESCRIPTION
  654. XReads a portable bitmap as input.
  655. XProduces PostScript as output.
  656. X.LP
  657. XThe -s flag controls the scale of the result.  The default scale is 1,
  658. Xwhich results in one pbm pixel producing a 3x3 square of PostScript
  659. Xpixels.  On a 300 dpi printer such as the Apple Laserwriter, this makes
  660. Xthe output look about the same size as the input would if it was displayed
  661. Xon a typical 72 dpi screen.
  662. XTo get one pbm pixel per PostScript pixel, use "-s 0.333333".
  663. X.LP
  664. XNote that there is no pstopbm
  665. Xtool - this transformation is one-way, because a pstopbm tool would
  666. Xbe a full-fledged PostScript interpreter, which is beyond the scope
  667. Xof this package.
  668. X.SH "SEE ALSO"
  669. Xpbm(5)
  670. X.SH AUTHOR
  671. XCopyright (C) 1988 by Jef Poskanzer.
  672. X
  673. XPermission to use, copy, modify, and distribute this software and its
  674. Xdocumentation for any purpose and without fee is hereby granted, provided
  675. Xthat the above copyright notice appear in all copies and that both that
  676. Xcopyright notice and this permission notice appear in supporting
  677. Xdocumentation.  This software is provided "as is" without express or
  678. Ximplied warranty.
  679. SHAR_EOF
  680. if test 1228 -ne "`wc -c < 'pbmtops.1'`"
  681. then
  682.     echo shar: error transmitting "'pbmtops.1'" '(should have been 1228 characters)'
  683. fi
  684. fi # end of overwriting check
  685. echo shar: extracting "'pbmtoptx.c'" '(1791 characters)'
  686. if test -f 'pbmtoptx.c'
  687. then
  688.     echo shar: will not over-write existing file "'pbmtoptx.c'"
  689. else
  690. sed 's/^X//' << \SHAR_EOF > 'pbmtoptx.c'
  691. X/* pbmtoptx.c - read a portable bitmap and produce a Printronix printer file
  692. X**
  693. X** Copyright (C) 1988 by Jef Poskanzer.
  694. X**
  695. X** Permission to use, copy, modify, and distribute this software and its
  696. X** documentation for any purpose and without fee is hereby granted, provided
  697. X** that the above copyright notice appear in all copies and that both that
  698. X** copyright notice and this permission notice appear in supporting
  699. X** documentation.  This software is provided "as is" without express or
  700. X** implied warranty.
  701. X*/
  702. X
  703. X#include <stdio.h>
  704. X#ifdef    OS_SYSV
  705. X#include <string.h>
  706. X#else    OS_SYSV
  707. X#include <strings.h>
  708. X#endif    OS_SYSV
  709. X#include "pbm.h"
  710. X
  711. Xmain( argc, argv )
  712. Xint argc;
  713. Xchar *argv[];
  714. X    {
  715. X    FILE *ifd;
  716. X    bit **bits;
  717. X    int rows, cols, row, col;
  718. X    char *usage = "usage:  %s [pbmfile]\n";
  719. X
  720. X    if ( argc > 2 )
  721. X    {
  722. X    fprintf( stderr, usage, argv[0] );
  723. X    exit( 1 );
  724. X    }
  725. X
  726. X    if ( argc == 2 )
  727. X    {
  728. X        ifd = fopen( argv[1], "r" );
  729. X        if ( ifd == NULL )
  730. X        {
  731. X        fprintf( stderr, "%s: can't open.\n", argv[1] );
  732. X        exit( 1 );
  733. X        }
  734. X    }
  735. X    else
  736. X    ifd = stdin;
  737. X
  738. X    bits = pbm_readpbm( ifd, &cols, &rows );
  739. X
  740. X    if ( ifd != stdin )
  741. X    fclose( ifd );
  742. X    
  743. X    putinit( );
  744. X    for ( row = 0; row < rows; row++ )
  745. X    {
  746. X    putchar( 5 );
  747. X        for ( col = 0; col < cols; col++ )
  748. X        putbit( bits[row][col] );
  749. X    putrest( );
  750. X    putchar( '\n' );
  751. X        }
  752. X
  753. X    exit( 0 );
  754. X    }
  755. X
  756. X
  757. Xchar item;
  758. Xint bitsperitem, bitshift;
  759. X
  760. Xputinit( )
  761. X    {
  762. X    bitsperitem = 0;
  763. X    item = 64;
  764. X    bitshift = 0;
  765. X    }
  766. X
  767. Xputbit( b )
  768. Xbit b;
  769. X    {
  770. X    if ( bitsperitem == 6 )
  771. X    putitem( );
  772. X    if ( b )
  773. X    item += 1 << bitshift;
  774. X    bitsperitem++;
  775. X    bitshift++;
  776. X    }
  777. X
  778. Xputrest( )
  779. X    {
  780. X    if ( bitsperitem > 0 )
  781. X    putitem( );
  782. X    }
  783. X
  784. Xputitem( )
  785. X    {
  786. X    putchar( item );
  787. X    bitsperitem = 0;
  788. X    item = 64;
  789. X    bitshift = 0;
  790. X    }
  791. SHAR_EOF
  792. if test 1791 -ne "`wc -c < 'pbmtoptx.c'`"
  793. then
  794.     echo shar: error transmitting "'pbmtoptx.c'" '(should have been 1791 characters)'
  795. fi
  796. fi # end of overwriting check
  797. echo shar: extracting "'pbmtoptx.1'" '(763 characters)'
  798. if test -f 'pbmtoptx.1'
  799. then
  800.     echo shar: will not over-write existing file "'pbmtoptx.1'"
  801. else
  802. sed 's/^X//' << \SHAR_EOF > 'pbmtoptx.1'
  803. X.TH pbmtoptx 1 "31 August 1988"
  804. X.SH NAME
  805. Xpbmtoptx - convert portable bitmaps into Printronix printer graphics
  806. X.SH SYNOPSIS
  807. Xpbmtoptx [pbmfile]
  808. X.SH DESCRIPTION
  809. XReads a portable bitmap as input.
  810. XProduces a file of Printronix printer graphics as output.
  811. X.LP
  812. XNote that there is no ptxtopbm tool - this transformation is one way.
  813. X.SH "SEE ALSO"
  814. Xpbm(5)
  815. X.SH AUTHOR
  816. XCopyright (C) 1988 by Jef Poskanzer.
  817. X
  818. XPermission to use, copy, modify, and distribute this software and its
  819. Xdocumentation for any purpose and without fee is hereby granted, provided
  820. Xthat the above copyright notice appear in all copies and that both that
  821. Xcopyright notice and this permission notice appear in supporting
  822. Xdocumentation.  This software is provided "as is" without express or
  823. Ximplied warranty.
  824. SHAR_EOF
  825. if test 763 -ne "`wc -c < 'pbmtoptx.1'`"
  826. then
  827.     echo shar: error transmitting "'pbmtoptx.1'" '(should have been 763 characters)'
  828. fi
  829. fi # end of overwriting check
  830. echo shar: extracting "'pbmtorast.c'" '(1849 characters)'
  831. if test -f 'pbmtorast.c'
  832. then
  833.     echo shar: will not over-write existing file "'pbmtorast.c'"
  834. else
  835. sed 's/^X//' << \SHAR_EOF > 'pbmtorast.c'
  836. X/* pbmtorast.c - read a portable bitmap and produce a Sun rasterfile
  837. X**
  838. X** Copyright (C) 1988 by Jef Poskanzer.
  839. X**
  840. X** Permission to use, copy, modify, and distribute this software and its
  841. X** documentation for any purpose and without fee is hereby granted, provided
  842. X** that the above copyright notice appear in all copies and that both that
  843. X** copyright notice and this permission notice appear in supporting
  844. X** documentation.  This software is provided "as is" without express or
  845. X** implied warranty.
  846. X*/
  847. X
  848. X#include <stdio.h>
  849. X#include "pbm.h"
  850. X
  851. X/* Because of the following include, this program compiles only on Suns. */
  852. X#include <pixrect/pixrect_hs.h>
  853. X
  854. Xmain( argc, argv )
  855. Xint argc;
  856. Xchar *argv[];
  857. X    {
  858. X    FILE *ifd;
  859. X    bit **bits;
  860. X    int linebytes;
  861. X    int rows, cols, row, col;
  862. X    struct pixrect *pr;
  863. X    short *data;
  864. X    int shortcount, bitcount;
  865. X
  866. X    if ( argc > 2 )
  867. X    {
  868. X    fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
  869. X    exit( 1 );
  870. X    }
  871. X
  872. X    if ( argc == 2 )
  873. X    {
  874. X    ifd = fopen( argv[1], "r" );
  875. X    if ( ifd == NULL )
  876. X        {
  877. X        fprintf( stderr, "%s: can't open.\n", argv[1] );
  878. X        exit( 1 );
  879. X        }
  880. X    }
  881. X    else
  882. X    ifd = stdin;
  883. X
  884. X    bits = pbm_readpbm( ifd, &cols, &rows );
  885. X
  886. X    if ( ifd != stdin )
  887. X    fclose( ifd );
  888. X    
  889. X    if ( (pr = mem_create(cols, rows, 1)) == NULL )
  890. X    {
  891. X    fprintf( stderr, "Unable to create new pixrect.\n");
  892. X    exit( 1 );
  893. X    }
  894. X
  895. X    data = ((struct mpr_data *)pr->pr_data)->md_image;
  896. X    linebytes = ((struct mpr_data *)pr->pr_data)->md_linebytes;
  897. X
  898. X    for ( row = 0; row < rows; row++ )
  899. X    {
  900. X    bitcount = 15;
  901. X    shortcount = 0;
  902. X    for ( col = 0; col < cols; col++ )
  903. X        {
  904. X        *(data + shortcount) |= (bits[row][col] << bitcount);
  905. X        bitcount--;
  906. X        if ( bitcount < 0 )
  907. X        {
  908. X        bitcount = 15;
  909. X        shortcount++;
  910. X        }
  911. X        }
  912. X    data += linebytes / sizeof(short);
  913. X    }
  914. X
  915. X    pr_dump( pr, stdout, NULL, RT_BYTE_ENCODED, 0 );
  916. X
  917. X    exit( 0 );
  918. X    }
  919. SHAR_EOF
  920. if test 1849 -ne "`wc -c < 'pbmtorast.c'`"
  921. then
  922.     echo shar: error transmitting "'pbmtorast.c'" '(should have been 1849 characters)'
  923. fi
  924. fi # end of overwriting check
  925. echo shar: extracting "'pbmtorast.1'" '(770 characters)'
  926. if test -f 'pbmtorast.1'
  927. then
  928.     echo shar: will not over-write existing file "'pbmtorast.1'"
  929. else
  930. sed 's/^X//' << \SHAR_EOF > 'pbmtorast.1'
  931. X.TH pbmtorast 1 "31 August 1988"
  932. X.SH NAME
  933. Xpbmtorast - convert portable bitmaps into Sun rasters
  934. X.SH SYNOPSIS
  935. Xpbmtorast [pbmfile]
  936. X.SH DESCRIPTION
  937. XReads a portable bitmap as input.
  938. XProduces a Sun raster file as output.
  939. XNOTE: since it uses Sun-specific include files, pbmtorast will compile
  940. Xonly on Suns.
  941. X.SH "SEE ALSO"
  942. Xrasttopbm(1), pbm(5)
  943. X.SH AUTHOR
  944. XBarry Klawans
  945. X
  946. XCopyright (C) 1988 by Jef Poskanzer.
  947. X
  948. XPermission to use, copy, modify, and distribute this software and its
  949. Xdocumentation for any purpose and without fee is hereby granted, provided
  950. Xthat the above copyright notice appear in all copies and that both that
  951. Xcopyright notice and this permission notice appear in supporting
  952. Xdocumentation.  This software is provided "as is" without express or
  953. Ximplied warranty.
  954. SHAR_EOF
  955. if test 770 -ne "`wc -c < 'pbmtorast.1'`"
  956. then
  957.     echo shar: error transmitting "'pbmtorast.1'" '(should have been 770 characters)'
  958. fi
  959. fi # end of overwriting check
  960. echo shar: extracting "'pbmtoxbm.c'" '(2593 characters)'
  961. if test -f 'pbmtoxbm.c'
  962. then
  963.     echo shar: will not over-write existing file "'pbmtoxbm.c'"
  964. else
  965. sed 's/^X//' << \SHAR_EOF > 'pbmtoxbm.c'
  966. X/* pbmtoxbm.c - read a portable bitmap and produce an X11 bitmap file
  967. X**
  968. X** Copyright (C) 1988 by Jef Poskanzer.
  969. X**
  970. X** Permission to use, copy, modify, and distribute this software and its
  971. X** documentation for any purpose and without fee is hereby granted, provided
  972. X** that the above copyright notice appear in all copies and that both that
  973. X** copyright notice and this permission notice appear in supporting
  974. X** documentation.  This software is provided "as is" without express or
  975. X** implied warranty.
  976. X*/
  977. X
  978. X#include <stdio.h>
  979. X#ifdef    OS_SYSV
  980. X#include <string.h>
  981. X#else    OS_SYSV
  982. X#include <strings.h>
  983. X#endif    OS_SYSV
  984. X#include "pbm.h"
  985. X
  986. Xmain( argc, argv )
  987. Xint argc;
  988. Xchar *argv[];
  989. X    {
  990. X    FILE *ifd;
  991. X    bit **bits;
  992. X    int rows, cols, padright, row, col;
  993. X    char name[100], *cp;
  994. X
  995. X    if ( argc > 2 )
  996. X    {
  997. X    fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
  998. X    exit( 1 );
  999. X    }
  1000. X
  1001. X    if ( argc == 2 )
  1002. X    {
  1003. X        ifd = fopen( argv[1], "r" );
  1004. X        if ( ifd == NULL )
  1005. X        {
  1006. X        fprintf( stderr, "%s: can't open.\n", argv[1] );
  1007. X        exit( 1 );
  1008. X        }
  1009. X    strcpy( name, argv[1] );
  1010. X
  1011. X#ifdef    OS_SYSV
  1012. X    if ( ( cp = strchr( name, '.' ) ) != 0 )
  1013. X#else    OS_SYSV
  1014. X    if ( ( cp = index( name, '.' ) ) != 0 )
  1015. X#endif    OS_SYSV
  1016. X        *cp = '\0';
  1017. X    }
  1018. X    else
  1019. X    {
  1020. X    ifd = stdin;
  1021. X    strcpy( name, "noname" );
  1022. X    }
  1023. X
  1024. X    bits = pbm_readpbm( ifd, &cols, &rows );
  1025. X
  1026. X    if ( ifd != stdin )
  1027. X    fclose( ifd );
  1028. X    
  1029. X    /* Compute padding to round cols up to the nearest multiple of 8. */
  1030. X    padright = ( ( cols + 7 ) / 8 ) * 8 - cols;
  1031. X
  1032. X    printf( "#define %s_width %d\n", name, cols );
  1033. X    printf( "#define %s_height %d\n", name, rows );
  1034. X    printf( "static char %s_bits[] = {\n", name );
  1035. X
  1036. X    putinit( );
  1037. X    for ( row = 0; row < rows; row++ )
  1038. X    {
  1039. X        for ( col = 0; col < cols; col++ )
  1040. X        putbit( bits[row][col] );
  1041. X    for ( col = 0; col < padright; col++ )
  1042. X        putbit( 0 );
  1043. X        }
  1044. X    putrest( );
  1045. X
  1046. X    exit( 0 );
  1047. X    }
  1048. X
  1049. X
  1050. Xint item, bitsperitem, bitshift, itemsperline, firstitem;
  1051. X
  1052. Xputinit( )
  1053. X    {
  1054. X    itemsperline = 0;
  1055. X    bitsperitem = 0;
  1056. X    item = 0;
  1057. X    bitshift = 0;
  1058. X    firstitem = 1;
  1059. X    }
  1060. X
  1061. Xputbit( b )
  1062. Xbit b;
  1063. X    {
  1064. X    if ( bitsperitem == 8 )
  1065. X    putitem( );
  1066. X    bitsperitem++;
  1067. X    if ( b )
  1068. X    item += 1 << bitshift;
  1069. X    bitshift++;
  1070. X    }
  1071. X
  1072. Xputrest( )
  1073. X    {
  1074. X    if ( bitsperitem > 0 )
  1075. X    putitem( );
  1076. X    printf( "};\n" );
  1077. X    }
  1078. X
  1079. Xputitem( )
  1080. X    {
  1081. X    if ( firstitem )
  1082. X    firstitem = 0;
  1083. X    else
  1084. X    printf( "," );
  1085. X    if ( itemsperline == 15 )
  1086. X    {
  1087. X    putchar( '\n' );
  1088. X    itemsperline = 0;
  1089. X    }
  1090. X    if ( itemsperline == 0 )
  1091. X    printf( " " );
  1092. X    itemsperline++;
  1093. X    printf( "0x%02x", item );
  1094. X    bitsperitem = 0;
  1095. X    item = 0;
  1096. X    bitshift = 0;
  1097. X    }
  1098. SHAR_EOF
  1099. if test 2593 -ne "`wc -c < 'pbmtoxbm.c'`"
  1100. then
  1101.     echo shar: error transmitting "'pbmtoxbm.c'" '(should have been 2593 characters)'
  1102. fi
  1103. fi # end of overwriting check
  1104. echo shar: extracting "'pbmtoxbm.1'" '(677 characters)'
  1105. if test -f 'pbmtoxbm.1'
  1106. then
  1107.     echo shar: will not over-write existing file "'pbmtoxbm.1'"
  1108. else
  1109. sed 's/^X//' << \SHAR_EOF > 'pbmtoxbm.1'
  1110. X.TH pbmtoxbm 1 "31 August 1988"
  1111. X.SH NAME
  1112. Xpbmtoxbm - convert portable bitmaps into X11 bitmaps
  1113. X.SH SYNOPSIS
  1114. Xpbmtoxbm [pbmfile]
  1115. X.SH DESCRIPTION
  1116. XReads a portable bitmap as input.
  1117. XProduces an X11 bitmap as output.
  1118. X.SH "SEE ALSO"
  1119. Xpbmtox10bm(1), xbmtopbm(1), pbm(5)
  1120. X.SH AUTHOR
  1121. XCopyright (C) 1988 by Jef Poskanzer.
  1122. X
  1123. XPermission to use, copy, modify, and distribute this software and its
  1124. Xdocumentation for any purpose and without fee is hereby granted, provided
  1125. Xthat the above copyright notice appear in all copies and that both that
  1126. Xcopyright notice and this permission notice appear in supporting
  1127. Xdocumentation.  This software is provided "as is" without express or
  1128. Ximplied warranty.
  1129. SHAR_EOF
  1130. if test 677 -ne "`wc -c < 'pbmtoxbm.1'`"
  1131. then
  1132.     echo shar: error transmitting "'pbmtoxbm.1'" '(should have been 677 characters)'
  1133. fi
  1134. fi # end of overwriting check
  1135. echo shar: extracting "'pbmtox10bm.c'" '(2601 characters)'
  1136. if test -f 'pbmtox10bm.c'
  1137. then
  1138.     echo shar: will not over-write existing file "'pbmtox10bm.c'"
  1139. else
  1140. sed 's/^X//' << \SHAR_EOF > 'pbmtox10bm.c'
  1141. X/* pbmtox10bm.c - read a portable bitmap and produce an X10 bitmap file
  1142. X**
  1143. X** Copyright (C) 1988 by Jef Poskanzer.
  1144. X**
  1145. X** Permission to use, copy, modify, and distribute this software and its
  1146. X** documentation for any purpose and without fee is hereby granted, provided
  1147. X** that the above copyright notice appear in all copies and that both that
  1148. X** copyright notice and this permission notice appear in supporting
  1149. X** documentation.  This software is provided "as is" without express or
  1150. X** implied warranty.
  1151. X*/
  1152. X
  1153. X#include <stdio.h>
  1154. X#ifdef    OS_SYSV
  1155. X#include <string.h>
  1156. X#else    OS_SYSV
  1157. X#include <strings.h>
  1158. X#endif    OS_SYSV
  1159. X#include "pbm.h"
  1160. X
  1161. Xmain( argc, argv )
  1162. Xint argc;
  1163. Xchar *argv[];
  1164. X    {
  1165. X    FILE *ifd;
  1166. X    bit **bits;
  1167. X    int rows, cols, padright, row, col;
  1168. X    char name[100], *cp;
  1169. X
  1170. X    if ( argc > 2 )
  1171. X    {
  1172. X    fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
  1173. X    exit( 1 );
  1174. X    }
  1175. X
  1176. X    if ( argc == 2 )
  1177. X    {
  1178. X        ifd = fopen( argv[1], "r" );
  1179. X        if ( ifd == NULL )
  1180. X        {
  1181. X        fprintf( stderr, "%s: can't open.\n", argv[1] );
  1182. X        exit( 1 );
  1183. X        }
  1184. X    strcpy( name, argv[1] );
  1185. X
  1186. X#ifdef    OS_SYSV
  1187. X    if ( ( cp = strchr( name, '.' ) ) != 0 )
  1188. X#else    OS_SYSV
  1189. X    if ( ( cp = index( name, '.' ) ) != 0 )
  1190. X#endif    OS_SYSV
  1191. X        *cp = '\0';
  1192. X    }
  1193. X    else
  1194. X    {
  1195. X    ifd = stdin;
  1196. X    strcpy( name, "noname" );
  1197. X    }
  1198. X
  1199. X    bits = pbm_readpbm( ifd, &cols, &rows );
  1200. X
  1201. X    if ( ifd != stdin )
  1202. X    fclose( ifd );
  1203. X    
  1204. X    /* Compute padding to round cols up to the nearest multiple of 16. */
  1205. X    padright = ( ( cols + 15 ) / 16 ) * 16 - cols;
  1206. X
  1207. X    printf( "#define %s_width %d\n", name, cols );
  1208. X    printf( "#define %s_height %d\n", name, rows );
  1209. X    printf( "static short %s_bits[] = {\n", name );
  1210. X
  1211. X    putinit( );
  1212. X    for ( row = 0; row < rows; row++ )
  1213. X    {
  1214. X        for ( col = 0; col < cols; col++ )
  1215. X        putbit( bits[row][col] );
  1216. X    for ( col = 0; col < padright; col++ )
  1217. X        putbit( 0 );
  1218. X        }
  1219. X    putrest( );
  1220. X
  1221. X    exit( 0 );
  1222. X    }
  1223. X
  1224. X
  1225. Xint item, bitsperitem, bitshift, itemsperline, firstitem;
  1226. X
  1227. Xputinit( )
  1228. X    {
  1229. X    itemsperline = 0;
  1230. X    bitsperitem = 0;
  1231. X    item = 0;
  1232. X    bitshift = 0;
  1233. X    firstitem = 1;
  1234. X    }
  1235. X
  1236. Xputbit( b )
  1237. Xbit b;
  1238. X    {
  1239. X    if ( bitsperitem == 16 )
  1240. X    putitem( );
  1241. X    bitsperitem++;
  1242. X    if ( b )
  1243. X    item += 1 << bitshift;
  1244. X    bitshift++;
  1245. X    }
  1246. X
  1247. Xputrest( )
  1248. X    {
  1249. X    if ( bitsperitem > 0 )
  1250. X    putitem( );
  1251. X    printf( "};\n" );
  1252. X    }
  1253. X
  1254. Xputitem( )
  1255. X    {
  1256. X    if ( firstitem )
  1257. X    firstitem = 0;
  1258. X    else
  1259. X    printf( "," );
  1260. X    if ( itemsperline == 11 )
  1261. X    {
  1262. X    putchar( '\n' );
  1263. X    itemsperline = 0;
  1264. X    }
  1265. X    if ( itemsperline == 0 )
  1266. X    printf( " " );
  1267. X    itemsperline++;
  1268. X    printf( "0x%04x", item );
  1269. X    bitsperitem = 0;
  1270. X    item = 0;
  1271. X    bitshift = 0;
  1272. X    }
  1273. SHAR_EOF
  1274. if test 2601 -ne "`wc -c < 'pbmtox10bm.c'`"
  1275. then
  1276.     echo shar: error transmitting "'pbmtox10bm.c'" '(should have been 2601 characters)'
  1277. fi
  1278. fi # end of overwriting check
  1279. echo shar: extracting "'pbmtox10bm.1'" '(827 characters)'
  1280. if test -f 'pbmtox10bm.1'
  1281. then
  1282.     echo shar: will not over-write existing file "'pbmtox10bm.1'"
  1283. else
  1284. sed 's/^X//' << \SHAR_EOF > 'pbmtox10bm.1'
  1285. X.TH pbmtox10bm 1 "31 August 1988"
  1286. X.SH NAME
  1287. Xpbmtox10bm - convert portable bitmaps into X10 bitmaps
  1288. X.SH SYNOPSIS
  1289. Xpbmtox10bm [pbmfile]
  1290. X.SH DESCRIPTION
  1291. XReads a portable bitmap as input.
  1292. XProduces an X10 bitmap as output.
  1293. XThis older format is maintained for compatibility.
  1294. X.LP
  1295. XNote that there is no x10bmtopbm tool, because
  1296. Xxbmtopbm can read both X11 and X10 bitmaps.
  1297. X.SH "SEE ALSO"
  1298. Xpbmtoxbm(1), xbmtopbm(1), pbm(5)
  1299. X.SH AUTHOR
  1300. XCopyright (C) 1988 by Jef Poskanzer.
  1301. X
  1302. XPermission to use, copy, modify, and distribute this software and its
  1303. Xdocumentation for any purpose and without fee is hereby granted, provided
  1304. Xthat the above copyright notice appear in all copies and that both that
  1305. Xcopyright notice and this permission notice appear in supporting
  1306. Xdocumentation.  This software is provided "as is" without express or
  1307. Ximplied warranty.
  1308. SHAR_EOF
  1309. if test 827 -ne "`wc -c < 'pbmtox10bm.1'`"
  1310. then
  1311.     echo shar: error transmitting "'pbmtox10bm.1'" '(should have been 827 characters)'
  1312. fi
  1313. fi # end of overwriting check
  1314. echo shar: extracting "'pbmtoascii.c'" '(1670 characters)'
  1315. if test -f 'pbmtoascii.c'
  1316. then
  1317.     echo shar: will not over-write existing file "'pbmtoascii.c'"
  1318. else
  1319. sed 's/^X//' << \SHAR_EOF > 'pbmtoascii.c'
  1320. X/* pbmtoascii.c - read a portable bitmap and produce ASCII graphics
  1321. X**
  1322. X** Copyright (C) 1988 by Jef Poskanzer.
  1323. X**
  1324. X** Permission to use, copy, modify, and distribute this software and its
  1325. X** documentation for any purpose and without fee is hereby granted, provided
  1326. X** that the above copyright notice appear in all copies and that both that
  1327. X** copyright notice and this permission notice appear in supporting
  1328. X** documentation.  This software is provided "as is" without express or
  1329. X** implied warranty.
  1330. X*/
  1331. X
  1332. X#include <stdio.h>
  1333. X#include "pbm.h"
  1334. X
  1335. Xmain( argc, argv )
  1336. Xint argc;
  1337. Xchar *argv[];
  1338. X    {
  1339. X    FILE *ifd;
  1340. X    bit **bits;
  1341. X    int rows, cols, row, col, lastcol;
  1342. X
  1343. X    if ( argc > 2 )
  1344. X    {
  1345. X    fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
  1346. X    exit( 1 );
  1347. X    }
  1348. X
  1349. X    if ( argc == 2 )
  1350. X    {
  1351. X        ifd = fopen( argv[1], "r" );
  1352. X        if ( ifd == NULL )
  1353. X        {
  1354. X        fprintf( stderr, "%s: can't open.\n", argv[1] );
  1355. X        exit( 1 );
  1356. X        }
  1357. X    }
  1358. X    else
  1359. X    ifd = stdin;
  1360. X
  1361. X    bits = pbm_readpbm( ifd, &cols, &rows );
  1362. X
  1363. X    if ( ifd != stdin )
  1364. X    fclose( ifd );
  1365. X    
  1366. X    /* Write out rows by twos. */
  1367. X    for ( row = 0; row < rows; row += 2 )
  1368. X    {
  1369. X    /* Find end of lines. */
  1370. X    for ( lastcol = cols-1; lastcol > 0; lastcol-- )
  1371. X        {
  1372. X        if ( bits[row][lastcol] )
  1373. X        break;
  1374. X        if ( row+1 < rows && bits[row+1][lastcol] )
  1375. X        break;
  1376. X        }
  1377. X        for ( col = 0; col <= lastcol; col++ )
  1378. X        {
  1379. X        if ( ! bits[row][col] )
  1380. X        {
  1381. X        if ( row+1 >= rows || ! bits[row+1][col] )
  1382. X            putchar( ' ' );
  1383. X        else
  1384. X            putchar( 'o' );
  1385. X        }
  1386. X        else
  1387. X        {
  1388. X        if ( row+1 >= rows || ! bits[row+1][col] )
  1389. X            putchar( '"' );
  1390. X        else
  1391. X            putchar( '$' );
  1392. X        }
  1393. X        }
  1394. X    putchar( '\n' );
  1395. X        }
  1396. X
  1397. X    exit( 0 );
  1398. X    }
  1399. SHAR_EOF
  1400. if test 1670 -ne "`wc -c < 'pbmtoascii.c'`"
  1401. then
  1402.     echo shar: error transmitting "'pbmtoascii.c'" '(should have been 1670 characters)'
  1403. fi
  1404. fi # end of overwriting check
  1405. echo shar: extracting "'pbmtoascii.1'" '(751 characters)'
  1406. if test -f 'pbmtoascii.1'
  1407. then
  1408.     echo shar: will not over-write existing file "'pbmtoascii.1'"
  1409. else
  1410. sed 's/^X//' << \SHAR_EOF > 'pbmtoascii.1'
  1411. X.TH pbmtoascii 1 "31 August 1988"
  1412. X.SH NAME
  1413. Xpbmtoascii - convert portable bitmaps into ASCII graphics
  1414. X.SH SYNOPSIS
  1415. Xpbmtoascii [pbmfile]
  1416. X.SH DESCRIPTION
  1417. XReads a portable bitmap as input.
  1418. XProduces a somewhat crude ASCII graphic as output.
  1419. X.LP
  1420. XNote that there is no asciitopbm tool - this transformation is one-way.
  1421. X.SH "SEE ALSO"
  1422. Xpbm(5)
  1423. X.SH AUTHOR
  1424. XCopyright (C) 1988 by Jef Poskanzer.
  1425. X
  1426. XPermission to use, copy, modify, and distribute this software and its
  1427. Xdocumentation for any purpose and without fee is hereby granted, provided
  1428. Xthat the above copyright notice appear in all copies and that both that
  1429. Xcopyright notice and this permission notice appear in supporting
  1430. Xdocumentation.  This software is provided "as is" without express or
  1431. Ximplied warranty.
  1432. SHAR_EOF
  1433. if test 751 -ne "`wc -c < 'pbmtoascii.1'`"
  1434. then
  1435.     echo shar: error transmitting "'pbmtoascii.1'" '(should have been 751 characters)'
  1436. fi
  1437. fi # end of overwriting check
  1438. echo shar: extracting "'pbmcatlr.c'" '(2899 characters)'
  1439. if test -f 'pbmcatlr.c'
  1440. then
  1441.     echo shar: will not over-write existing file "'pbmcatlr.c'"
  1442. else
  1443. sed 's/^X//' << \SHAR_EOF > 'pbmcatlr.c'
  1444. X/* pbmcatlr.c - concatenate portable bitmaps left to right
  1445. X**
  1446. X** Copyright (C) 1988 by Jef Poskanzer.
  1447. X**
  1448. X** Permission to use, copy, modify, and distribute this software and its
  1449. X** documentation for any purpose and without fee is hereby granted, provided
  1450. X** that the above copyright notice appear in all copies and that both that
  1451. X** copyright notice and this permission notice appear in supporting
  1452. X** documentation.  This software is provided "as is" without express or
  1453. X** implied warranty.
  1454. X*/
  1455. X
  1456. X#include <stdio.h>
  1457. X#include "pbm.h"
  1458. X
  1459. X#define MAXFILES 100
  1460. X
  1461. Xmain( argc, argv )
  1462. Xint argc;
  1463. Xchar *argv[];
  1464. X    {
  1465. X    FILE *ifd[MAXFILES];
  1466. X    bit **bits[MAXFILES], **newbits, background;
  1467. X    int argn, backdefault, nfiles, i, c;
  1468. X    int rows[MAXFILES], cols[MAXFILES], row, col;
  1469. X    int newrows, newcols, newcol, padtop;
  1470. X    char *usage = "usage:  %s [-0]/[-w]/[-1]/[-b] pbmfile pbmfile ...\n";
  1471. X
  1472. X    argn = 1;
  1473. X    backdefault = 1;
  1474. X
  1475. X    /* Check for flags. */
  1476. X    if ( argn < argc )
  1477. X    {
  1478. X    if ( argv[argn][0] == '-' )
  1479. X        {
  1480. X        if ( ( argv[argn][1] == '0' || argv[argn][1] == 'w' ||
  1481. X           argv[argn][1] == 'W') && argv[argn][2] == '\0' )
  1482. X        {
  1483. X        backdefault = 0;
  1484. X        background = 0;
  1485. X        }
  1486. X        else if ( ( argv[argn][1] == '1' || argv[argn][1] == 'b' ||
  1487. X            argv[argn][1] == 'B' ) && argv[argn][2] == '\0' )
  1488. X        {
  1489. X        backdefault = 0;
  1490. X        background = 1;
  1491. X        }
  1492. X        else
  1493. X        {
  1494. X        fprintf( stderr, usage, argv[0] );
  1495. X        exit( 1 );
  1496. X        }
  1497. X        argn++;
  1498. X        }
  1499. X    }
  1500. X
  1501. X    if ( argn < argc )
  1502. X    {
  1503. X    nfiles = argc - argn;
  1504. X    for ( i = 0; i < nfiles; i++ )
  1505. X        {
  1506. X        if ( strcmp( argv[argn+i], "-" ) == 0 )
  1507. X        ifd[i] = stdin;
  1508. X        else
  1509. X        {
  1510. X        ifd[i] = fopen( argv[argn+i], "r" );
  1511. X        if ( ifd[i] == NULL )
  1512. X            {
  1513. X            fprintf( stderr, "%s: can't open.\n", argv[argn+i] );
  1514. X            exit( 1 );
  1515. X            }
  1516. X        }
  1517. X        }
  1518. X    }
  1519. X    else
  1520. X    {
  1521. X    nfiles = 1;
  1522. X    ifd[0] = stdin;
  1523. X    }
  1524. X
  1525. X    newcols = 0;
  1526. X    newrows = 0;
  1527. X    for ( i = 0; i < nfiles; i++ )
  1528. X    {
  1529. X    bits[i] = pbm_readpbm( ifd[i], &cols[i], &rows[i] );
  1530. X    if ( ifd[i] != stdin )
  1531. X        fclose( ifd[i] );
  1532. X    newcols += cols[i];
  1533. X    if ( rows[i] > newrows )
  1534. X        newrows = rows[i];
  1535. X    }
  1536. X
  1537. X    newbits = pbm_allocarray( newcols, newrows );
  1538. X
  1539. X    newcol = 0;
  1540. X
  1541. X    for ( i = 0; i < nfiles; i++ )
  1542. X    {
  1543. X    if ( backdefault )
  1544. X        {
  1545. X        /* Make a reasonable guess as to what the background is. */
  1546. X        c = (int) bits[i][0][0] + (int) bits[i][0][cols[i]-1] +
  1547. X        (int) bits[i][rows[i]-1][0] +
  1548. X        (int) bits[i][rows[i]-1][cols[i]-1];
  1549. X        background = ( c <= 2 ) ? 0 : 1;
  1550. X        }
  1551. X
  1552. X    padtop = (newrows - rows[i]) / 2;
  1553. X
  1554. X    for ( col = 0; col <= cols[i]; col++ )
  1555. X        {
  1556. X        for ( row = 0; row < padtop; row++ )
  1557. X        newbits[row][newcol+col] = background;
  1558. X        for ( row = 0; row < rows[i]; row++ )
  1559. X        newbits[padtop+row][newcol+col] = bits[i][row][col];
  1560. X        for ( row = padtop+rows[i]; row < newrows; row++ )
  1561. X        newbits[row][newcol+col] = background;
  1562. X        }
  1563. X
  1564. X    newcol += cols[i];
  1565. X    }
  1566. X
  1567. X    pbm_writepbm( stdout, newbits, newcols, newrows );
  1568. X
  1569. X    exit( 0 );
  1570. X    }
  1571. SHAR_EOF
  1572. if test 2899 -ne "`wc -c < 'pbmcatlr.c'`"
  1573. then
  1574.     echo shar: error transmitting "'pbmcatlr.c'" '(should have been 2899 characters)'
  1575. fi
  1576. fi # end of overwriting check
  1577. echo shar: extracting "'pbmcatlr.1'" '(994 characters)'
  1578. if test -f 'pbmcatlr.1'
  1579. then
  1580.     echo shar: will not over-write existing file "'pbmcatlr.1'"
  1581. else
  1582. sed 's/^X//' << \SHAR_EOF > 'pbmcatlr.1'
  1583. X.TH pbmcatlr 1 "31 August 1988"
  1584. X.SH NAME
  1585. Xpbmcatlr - concatenate portable bitmaps left to right
  1586. X.SH SYNOPSIS
  1587. Xpbmcatlr [-0]/[-w]/[-1]/[-b] pbmfile pbmfile ...
  1588. X.SH DESCRIPTION
  1589. XReads portable bitmaps as input.
  1590. XConcatenates them left to right and produces a portable bitmap as output.
  1591. XIf the bitmaps are not all the same height, the shorter ones are centered
  1592. Xvertically with the edges filled in.
  1593. XThe -0/-w and -1/-b flags specify what color to use for this fill -- if neither
  1594. Xis specified, the program makes a guess as to which would look better.
  1595. X.SH "SEE ALSO"
  1596. Xpbmcattb(1), pbm(5)
  1597. X.SH AUTHOR
  1598. XCopyright (C) 1988 by Jef Poskanzer.
  1599. X
  1600. XPermission to use, copy, modify, and distribute this software and its
  1601. Xdocumentation for any purpose and without fee is hereby granted, provided
  1602. Xthat the above copyright notice appear in all copies and that both that
  1603. Xcopyright notice and this permission notice appear in supporting
  1604. Xdocumentation.  This software is provided "as is" without express or
  1605. Ximplied warranty.
  1606. SHAR_EOF
  1607. if test 994 -ne "`wc -c < 'pbmcatlr.1'`"
  1608. then
  1609.     echo shar: error transmitting "'pbmcatlr.1'" '(should have been 994 characters)'
  1610. fi
  1611. fi # end of overwriting check
  1612. echo shar: extracting "'pbmcattb.c'" '(2905 characters)'
  1613. if test -f 'pbmcattb.c'
  1614. then
  1615.     echo shar: will not over-write existing file "'pbmcattb.c'"
  1616. else
  1617. sed 's/^X//' << \SHAR_EOF > 'pbmcattb.c'
  1618. X/* pbmcattb.c - concatenate portable bitmaps top to bottom
  1619. X**
  1620. X** Copyright (C) 1988 by Jef Poskanzer.
  1621. X**
  1622. X** Permission to use, copy, modify, and distribute this software and its
  1623. X** documentation for any purpose and without fee is hereby granted, provided
  1624. X** that the above copyright notice appear in all copies and that both that
  1625. X** copyright notice and this permission notice appear in supporting
  1626. X** documentation.  This software is provided "as is" without express or
  1627. X** implied warranty.
  1628. X*/
  1629. X
  1630. X#include <stdio.h>
  1631. X#include "pbm.h"
  1632. X
  1633. X#define MAXFILES 100
  1634. X
  1635. Xmain( argc, argv )
  1636. Xint argc;
  1637. Xchar *argv[];
  1638. X    {
  1639. X    FILE *ifd[MAXFILES];
  1640. X    bit **bits[MAXFILES], **newbits, background;
  1641. X    int argn, backdefault, nfiles, i, c;
  1642. X    int rows[MAXFILES], cols[MAXFILES], row, col;
  1643. X    int newrows, newcols, newrow, padleft;
  1644. X    char *usage = "usage:  %s [-0]/[-w]/[-1]/[-b] pbmfile pbmfile ...\n";
  1645. X
  1646. X    argn = 1;
  1647. X    backdefault = 1;
  1648. X
  1649. X    /* Check for flags. */
  1650. X    if ( argn < argc )
  1651. X    {
  1652. X    if ( argv[argn][0] == '-' )
  1653. X        {
  1654. X        if ( ( argv[argn][1] == '0' || argv[argn][1] == 'w' ||
  1655. X           argv[argn][1] == 'W' ) && argv[argn][2] == '\0' )
  1656. X        {
  1657. X        backdefault = 0;
  1658. X        background = 0;
  1659. X        }
  1660. X        else if ( ( argv[argn][1] == '1' || argv[argn][1] == 'b' ||
  1661. X            argv[argn][1] == 'B' ) && argv[argn][2] == '\0' )
  1662. X        {
  1663. X        backdefault = 0;
  1664. X        background = 1;
  1665. X        }
  1666. X        else
  1667. X        {
  1668. X        fprintf( stderr, usage, argv[0] );
  1669. X        exit( 1 );
  1670. X        }
  1671. X        argn++;
  1672. X        }
  1673. X    }
  1674. X
  1675. X    if ( argn < argc )
  1676. X    {
  1677. X    nfiles = argc - argn;
  1678. X    for ( i = 0; i < nfiles; i++ )
  1679. X        {
  1680. X        if ( strcmp( argv[argn+i], "-" ) == 0 )
  1681. X        ifd[i] = stdin;
  1682. X        else
  1683. X        {
  1684. X        ifd[i] = fopen( argv[argn+i], "r" );
  1685. X        if ( ifd[i] == NULL )
  1686. X            {
  1687. X            fprintf( stderr, "%s: can't open.\n", argv[argn+i] );
  1688. X            exit( 1 );
  1689. X            }
  1690. X        }
  1691. X        }
  1692. X    }
  1693. X    else
  1694. X    {
  1695. X    nfiles = 1;
  1696. X    ifd[0] = stdin;
  1697. X    }
  1698. X
  1699. X    newcols = 0;
  1700. X    newrows = 0;
  1701. X    for ( i = 0; i < nfiles; i++ )
  1702. X    {
  1703. X    bits[i] = pbm_readpbm( ifd[i], &cols[i], &rows[i] );
  1704. X    if ( ifd[i] != stdin )
  1705. X        fclose( ifd[i] );
  1706. X    if ( cols[i] > newcols )
  1707. X        newcols = cols[i];
  1708. X    newrows += rows[i];
  1709. X    }
  1710. X
  1711. X    newbits = pbm_allocarray( newcols, newrows );
  1712. X
  1713. X    newrow = 0;
  1714. X
  1715. X    for ( i = 0; i < nfiles; i++ )
  1716. X    {
  1717. X    if ( backdefault )
  1718. X        {
  1719. X        /* Make a reasonable guess as to what the background is. */
  1720. X        c = (int) bits[i][0][0] + (int) bits[i][0][cols[i]-1] +
  1721. X        (int) bits[i][rows[i]-1][0] +
  1722. X        (int) bits[i][rows[i]-1][cols[i]-1];
  1723. X        background = ( c <= 2 ) ? 0 : 1;
  1724. X        }
  1725. X
  1726. X    padleft = (newcols - cols[i]) / 2;
  1727. X
  1728. X    for ( row = 0; row < rows[i]; row++ )
  1729. X        {
  1730. X        for ( col = 0; col < padleft; col++ )
  1731. X        newbits[newrow+row][col] = background;
  1732. X        for ( col = 0; col <= cols[i]; col++ )
  1733. X        newbits[newrow+row][padleft+col] = bits[i][row][col];
  1734. X        for ( col = padleft+cols[i]; col < newcols; col++ )
  1735. X        newbits[newrow+row][col] = background;
  1736. X        }
  1737. X
  1738. X    newrow += rows[i];
  1739. X    }
  1740. X
  1741. X    pbm_writepbm( stdout, newbits, newcols, newrows );
  1742. X
  1743. X    exit( 0 );
  1744. X    }
  1745. SHAR_EOF
  1746. if test 2905 -ne "`wc -c < 'pbmcattb.c'`"
  1747. then
  1748.     echo shar: error transmitting "'pbmcattb.c'" '(should have been 2905 characters)'
  1749. fi
  1750. fi # end of overwriting check
  1751. echo shar: extracting "'pbmcattb.1'" '(996 characters)'
  1752. if test -f 'pbmcattb.1'
  1753. then
  1754.     echo shar: will not over-write existing file "'pbmcattb.1'"
  1755. else
  1756. sed 's/^X//' << \SHAR_EOF > 'pbmcattb.1'
  1757. X.TH pbmcattb 1 "31 August 1988"
  1758. X.SH NAME
  1759. Xpbmcattb - concatenate portable bitmaps top to bottom
  1760. X.SH SYNOPSIS
  1761. Xpbmcattb [-0]/[-w]/[-1]/[-b] pbmfile pbmfile ...
  1762. X.SH DESCRIPTION
  1763. XReads portable bitmaps as input.
  1764. XConcatenates them top to bottom and produces a portable bitmap as output.
  1765. XIf the bitmaps are not all the same width, the narrower ones are centered
  1766. Xhorizontally with the edges filled in.
  1767. XThe -0/-w and -1/-b flags specify what color to use for this fill -- if neither
  1768. Xis specified, the program makes a guess as to which would look better.
  1769. X.SH "SEE ALSO"
  1770. Xpbmcatlr(1), pbm(5)
  1771. X.SH AUTHOR
  1772. XCopyright (C) 1988 by Jef Poskanzer.
  1773. X
  1774. XPermission to use, copy, modify, and distribute this software and its
  1775. Xdocumentation for any purpose and without fee is hereby granted, provided
  1776. Xthat the above copyright notice appear in all copies and that both that
  1777. Xcopyright notice and this permission notice appear in supporting
  1778. Xdocumentation.  This software is provided "as is" without express or
  1779. Ximplied warranty.
  1780. SHAR_EOF
  1781. if test 996 -ne "`wc -c < 'pbmcattb.1'`"
  1782. then
  1783.     echo shar: error transmitting "'pbmcattb.1'" '(should have been 996 characters)'
  1784. fi
  1785. fi # end of overwriting check
  1786. echo shar: extracting "'pbmfliplr.c'" '(1305 characters)'
  1787. if test -f 'pbmfliplr.c'
  1788. then
  1789.     echo shar: will not over-write existing file "'pbmfliplr.c'"
  1790. else
  1791. sed 's/^X//' << \SHAR_EOF > 'pbmfliplr.c'
  1792. X/* pbmfliplr.c - read a portable bitmap and flip it left for right
  1793. X**
  1794. X** Copyright (C) 1988 by Jef Poskanzer.
  1795. X**
  1796. X** Permission to use, copy, modify, and distribute this software and its
  1797. X** documentation for any purpose and without fee is hereby granted, provided
  1798. X** that the above copyright notice appear in all copies and that both that
  1799. X** copyright notice and this permission notice appear in supporting
  1800. X** documentation.  This software is provided "as is" without express or
  1801. X** implied warranty.
  1802. X*/
  1803. X
  1804. X#include <stdio.h>
  1805. X#include "pbm.h"
  1806. X
  1807. Xmain( argc, argv )
  1808. Xint argc;
  1809. Xchar *argv[];
  1810. X    {
  1811. X    FILE *ifd;
  1812. X    bit **bits, b;
  1813. X    int rows, cols, row, col;
  1814. X
  1815. X    if ( argc > 2 )
  1816. X    {
  1817. X    fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
  1818. X    exit( 1 );
  1819. X    }
  1820. X
  1821. X    if ( argc == 2 )
  1822. X    {
  1823. X        ifd = fopen( argv[1], "r" );
  1824. X        if ( ifd == NULL )
  1825. X        {
  1826. X        fprintf( stderr, "%s: can't open.\n", argv[1] );
  1827. X        exit( 1 );
  1828. X        }
  1829. X    }
  1830. X    else
  1831. X    ifd = stdin;
  1832. X
  1833. X    bits = pbm_readpbm( ifd, &cols, &rows );
  1834. X
  1835. X    if ( ifd != stdin )
  1836. X    fclose( ifd );
  1837. X
  1838. X    for ( row = 0; row < rows; row++ )
  1839. X        for ( col = 0; col < cols / 2; col++ )
  1840. X        {
  1841. X        b = bits[row][col];
  1842. X        bits[row][col] = bits[row][cols-col-1];
  1843. X        bits[row][cols-col-1] = b;
  1844. X        }
  1845. X
  1846. X    pbm_writepbm( stdout, bits, cols, rows );
  1847. X
  1848. X    exit( 0 );
  1849. X    }
  1850. SHAR_EOF
  1851. if test 1305 -ne "`wc -c < 'pbmfliplr.c'`"
  1852. then
  1853.     echo shar: error transmitting "'pbmfliplr.c'" '(should have been 1305 characters)'
  1854. fi
  1855. fi # end of overwriting check
  1856. echo shar: extracting "'pbmfliplr.1'" '(709 characters)'
  1857. if test -f 'pbmfliplr.1'
  1858. then
  1859.     echo shar: will not over-write existing file "'pbmfliplr.1'"
  1860. else
  1861. sed 's/^X//' << \SHAR_EOF > 'pbmfliplr.1'
  1862. X.TH pbmfliplr 1 "31 August 1988"
  1863. X.SH NAME
  1864. Xpbmfliplr - flip a portable bitmap left for right
  1865. X.SH SYNOPSIS
  1866. Xpbmfliplr [pbmfile]
  1867. X.SH DESCRIPTION
  1868. XReads a portable bitmap as input.
  1869. XFlips it left for right and produces a portable bitmap as output.
  1870. X.SH "SEE ALSO"
  1871. Xpbmfliptb(1), pbmtrnspos(1), pbm(5)
  1872. X.SH AUTHOR
  1873. XCopyright (C) 1988 by Jef Poskanzer.
  1874. X
  1875. XPermission to use, copy, modify, and distribute this software and its
  1876. Xdocumentation for any purpose and without fee is hereby granted, provided
  1877. Xthat the above copyright notice appear in all copies and that both that
  1878. Xcopyright notice and this permission notice appear in supporting
  1879. Xdocumentation.  This software is provided "as is" without express or
  1880. Ximplied warranty.
  1881. SHAR_EOF
  1882. if test 709 -ne "`wc -c < 'pbmfliplr.1'`"
  1883. then
  1884.     echo shar: error transmitting "'pbmfliplr.1'" '(should have been 709 characters)'
  1885. fi
  1886. fi # end of overwriting check
  1887. #    End of shell archive
  1888. exit 0
  1889.